//go:build ignore

package define

import (
	kahttpreq "kiwi/actor/net/http/request"
	"time"

	aactor "github.com/asynkron/protoactor-go/actor"

	katimer "kiwi/actor/timer"
	klog "kiwi/log"
)

// IActor 供Super子类调用的接口
type IActor interface {
	PID() *aactor.PID
	ParentPID() *aactor.PID

	Sign() string
	// SetSign 线程不安全
	SetSign(sign string)

	Start(ctx aactor.Context, name string, startFunc func() error, wait bool) (err error)
	HasStop() bool
	Stop(stopFunc func(), wait bool) error

	Logger() klog.ILogger
	Debug(args ...any)
	Debugf(format string, args ...any)
	Info(args ...any)
	Infof(format string, args ...any)
	Warn(args ...any)
	Warnf(format string, args ...any)
	Error(args ...any)
	Errorf(format string, args ...any)

	NewTimer(dur time.Duration, tag katimer.Tag, cb katimer.Callback) katimer.ID
	NewLoopTimer(dur time.Duration, tag katimer.Tag, cb katimer.Callback) katimer.ID
	StopTimer(id katimer.ID) error

	NewHttpRequest(timeout time.Duration, tag kahttpreq.Tag, onPrepareFunc kahttpreq.OnPrepareFunc, onCompletedFunc kahttpreq.OnCompletedFunc) (requestID kahttpreq.ID, err error)
}

// IActorImplement 供Actor调用的接口
type IActorImplement interface {
	Destroy()

	OnStarted(ctx aactor.Context)
	OnStopping(ctx aactor.Context)
	OnStopped(ctx aactor.Context)
	OnReceiveMessage(ctx aactor.Context)
	OnActorTerminated(who *aactor.PID, ctx aactor.Context)
	OnRestarting(aactor.Context)
	OnRestarted(ctx aactor.Context)

	BeforeTriggerTimer(id katimer.ID, tag katimer.Tag, ctx aactor.Context) (ok bool, err error)
	AfterTriggerTimer(err error, id katimer.ID, tag katimer.Tag, ctx aactor.Context)

	BeforeCompleteHttpRequest(id kahttpreq.ID, tag kahttpreq.Tag, ctx aactor.Context) (ok bool, err error)
	AfterCompleteHttpRequest(err error, id kahttpreq.ID, tag kahttpreq.Tag, ctx aactor.Context)
}
